/**
 * the audio system bridge sf2synth.js to rsynthesizer
 */
jweb.util.SynthBridge = function() {
  this.subscriberId=null;
  this.wmlGainNode = null;
  this.synthGainNode = null;
  this.start();
}
jweb.util.SynthBridge.prototype= {
	onMessage:function(subj, msg, data) {
		if(subj == constants.waveTableNodeReady){
			this.wmlGainNode= msg.audioNode;
		}
		else if(subj == constants.synthNodeReady){
			this.synthGainNode= msg.audioNode;
		}
		
		if(this.synthGainNode!=null && this.wmlGainNode!=null){
			this.wmlGainNode.connect(this.synthGainNode);//now bridge two systems
		}
	},
	start:function() {
		if(this.subscriberId==null) this.subscriberId='**';
		this.subscriberId = window.PageBus.subscribe('**', this, this.onMessage, null);
	},
	stop:function() {
		if(this.subscriberId!=null){
			window.PageBus.unsubscribe(this.subscriberId);
			this.subscriberId=null;
		}
	}
}